package com.lh.io.bio.chat;

import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {

    public static void main(String[] args) {

        try {
            Socket socket = new Socket("127.0.0.1", 8888);
            PrintStream print = new PrintStream(socket.getOutputStream());
            Scanner scan = new Scanner(System.in);
            while (true){
                System.out.print("发送的消息:");
                String msg = scan.nextLine();
                if (msg.equalsIgnoreCase("exit")){
                    return;
                }
                print.println(msg);
                print.flush();

            }

        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
